package com.banyiyi.simple.pattern.chainOR;

/**
 * @ClassName ChainClient
 * @Description TODO
 * @Author yangwm
 * @Date 2023/2/16 16:55
 * @Version 1.0
 */
public class ChainClient {



    private static Handler getChainOfResponsibilityHandler(){
        // 设置责任链
        DebuggerHandler debugHandler = new DebuggerHandler(Handler.DEBUGGER);
        InfoHandler infoHandler = new InfoHandler(Handler.INFO);
        ErrorHandler errorHandler = new ErrorHandler(Handler.ERROR);

        debugHandler.setHandler(infoHandler);
        infoHandler.setHandler(errorHandler);

        return debugHandler;
    }

    public static void main(String[] args) {

        Handler handler = getChainOfResponsibilityHandler();

        handler.log(1);
        handler.log(2);
        handler.log(3);
        handler.log(4);
    }

}
